package com.softtown.modules.workflow.service.impl;


import com.softtown.common.service.impl.BaseServiceImpl;
import com.softtown.modules.workflow.dao.SwfProcPhaseDao;
import com.softtown.modules.workflow.dto.SwfProcPhaseDTO;
import com.softtown.modules.workflow.entity.SwfProcPhaseEntity;
import com.softtown.modules.workflow.service.SwfProcPhaseService;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author: Dingyayong
 * @Date: 2019/8/22 13:57
 * @Description: 流程实例审批段
 */
@Service
public class SwfProcPhaseServiceImpl extends BaseServiceImpl<SwfProcPhaseDao, SwfProcPhaseEntity> implements SwfProcPhaseService {

    /**
     * 找出差旅报销单审批段第一个审批段
     *
     * @param compId     公司id
     * @param procInstId 流程实例id
     * @return com.softtown.modules.entity.SwfProcPhaseEntity
     * @Author Dingyayong
     * @Date 2020/4/13 19:46
     */
    @Override
    public SwfProcPhaseEntity getActHeadFristSort(Long compId, Long procInstId) {
        return baseDao.getActHeadFristSort(compId, procInstId);
    }

    /**
     * 找出差旅报销单审批段最后一个审批段
     *
     * @param compId     公司id
     * @param procInstId 流程实例id
     * @return com.softtown.modules.entity.SwfProcPhaseEntity
     * @Author Dingyayong
     * @Date 2020/4/13 19:48
     */
    @Override
    public SwfProcPhaseEntity getActHeadLast(Long compId, Long procInstId) {
        return baseDao.getActHeadLast(compId, procInstId);
    }

    /**
     * 找出差旅报销单审批段当前审批段定义
     *
     * @param compId     公司id
     * @param phaseId    审批段id
     * @param procInstId 流程实例id
     * @return com.softtown.modules.entity.SwfProcPhaseEntity
     * @Author Dingyayong
     * @Date 2020/4/13 19:49
     */
    @Override
    public SwfProcPhaseEntity getActHeadByNow(Long compId, Long phaseId, Long procInstId) {
        return baseDao.getActHeadByNow(compId, phaseId, procInstId);
    }

    /**
     * 找出差旅报销单审批段当前审批段定义的下个审批段定义
     *
     * @param compId     公司id
     * @param procInstId 流程实例id
     * @param sortNum    序号
     * @return com.softtown.modules.entity.SwfProcPhaseEntity
     * @Author Dingyayong
     * @Date 2020/4/13 19:50
     */
    @Override
    public SwfProcPhaseEntity getActHeadNextBySort(Long compId, Long procInstId, Integer sortNum) {
        return baseDao.getActHeadNextBySort(compId, procInstId, sortNum);
    }

    /**
     * 找出当前单据已有的流程审批段（按照sort_num排序）
     *
     * @param swfProcPhaseDTO 流程实例DTO
     * @return java.util.List<com.softtown.modules.entity.SwfProcPhaseEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 19:51
     */
    @Override
    public List<SwfProcPhaseEntity> getSwfProcPhaseListBySort(SwfProcPhaseDTO swfProcPhaseDTO) {
        return baseDao.getSwfProcPhaseListBySort(swfProcPhaseDTO.getCompId(), swfProcPhaseDTO.getProcInstId());
    }

    /**
     * 找出当前单据已有的流程审批段（按照sort_num排序）
     *
     * @param compId     公司id
     * @param procInstId 流程实例id
     * @return java.util.List<com.softtown.modules.entity.SwfProcPhaseEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 19:52
     */
    @Override
    public List<SwfProcPhaseEntity> getSwfProcPhaseBySortList(Long compId, Long procInstId) {
        return baseDao.getSwfProcPhaseListBySort(compId, procInstId);
    }

    /**
     * 找出流程审批段按照id
     *
     * @param phaseId 审批段id
     * @return java.util.List<com.softtown.modules.entity.SwfProcPhaseEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 19:53
     */
    @Override
    public List<SwfProcPhaseEntity> getSwfProcPhaseByPhaseIdList(Long phaseId) {
        return baseDao.getSwfProcPhaseByPhaseIdList(phaseId);
    }
}
